/*
 * @lc app=leetcode.cn id=349 lang=typescript
 *
 * [349] 两个数组的交集
 */

// @lc code=start
function intersection(nums1: number[], nums2: number[]): number[] {
  const res:Set<number> = new Set()
  const num1Set = new Set(nums1)
  for (let i of nums2) {
    if (num1Set.has(i)) {
      res.add(i)
    }
  }
  return Array.from(res)
};
// @lc code=end

